<div id="viewer-container" class="viewer-container"></div>
<script>
  let viewer = undefined

  function loadBuild(){
    let layer = new DC.TilesetLayer('layer_build').addTo(viewer)
    let build = new DC.Tileset(
      '//resource.dvgis.cn/data/3dtiles/sz/tileset.json',
      {skipLevels:true}
    )
    let fs = `
       varying vec3 v_positionEC;
       void main(void){
           vec4 position = czm_inverseModelView * vec4(v_positionEC,1); // 位置
           float glowRange = 100.0; // 光环的移动范围(高度)
           gl_FragColor = vec4(0.2,  0.5, 1.0, 1.0); // 颜色
           gl_FragColor *= vec4(vec3(position.z / 100.0), 1.0); // 渐变
           // 动态光环
           float time = fract(czm_frameNumber / 360.0);
           time = abs(time - 0.5) * 2.0;
           float diff = step(0.005, abs( clamp(position.z / glowRange, 0.0, 1.0) - time));
           gl_FragColor.rgb += gl_FragColor.rgb * (1.0 - diff);
       }
      `
    build.setCustomShader(fs)
    layer.addOverlay(build)
    viewer.flyTo(build)
  }
      DC.config.baseUrl = '../libs/dc-sdk/resources/'
      let viewer = new DC.Viewer('viewer-container')
    let  baseLayer = DC.ImageryLayerFactory.createAMapImageryLayer({
      style: 'img',
      crs:'WGS84'
    })
     baseLayer.defaultBrightness = 0.05
    viewer.addBaseLayer([ baseLayer])
    let terrain = DC.TerrainFactory.createUrlTerrain({
      url: 'http://data.marsgis.cn/terrain'
    })
    viewer.addTerrain(terrain)
    loadBuild()
  }


</script>
